﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BasePlatformCommon;

namespace L9SubSet.WriteAddrPro
{
	public partial class Form_DelPortDataMode : Form
	{
		public string delMode = "selected";

		private string section = "DelPortDataMode";			// 多语言文件配置节名称

		private string tip = "提示";							// MessageBox 题头

		/*****************************************************************************************/

		// 构造函数
		public Form_DelPortDataMode()
		{
			InitializeComponent();

			this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
			this.Font = new System.Drawing.Font(this.Font.Name, 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134)));

			// 设置本地化语言
			if (LanguageOper.available == true)
			{
				setLanguageText();
			}
		}

		// 设置本地化语言
		public void setLanguageText()
		{
			if (LanguageOper.available == false)
			{
				return;
			}

			LanguageOper.SetCurrentCulture();

			tip = LanguageOper.ReadValue("Common", "tipStr");

			// 界面控件文字
			this.Text = LanguageOper.ReadValue(section, "delPortDataMode.Text");
			allSubRadioButton.Text = LanguageOper.ReadValue(section, "delPortDataMode.Text");
			currentSubRadioButton.Text = LanguageOper.ReadValue(section, "currentSubRadioButton.Text");
			allRadioButton.Text = LanguageOper.ReadValue(section, "allRadioButton.Text");
			selectedRadioButton.Text = LanguageOper.ReadValue(section, "selectedRadioButton.Text");
			okButton.Text = LanguageOper.ReadValue(section, "okButton.Text");
			if (LanguageOper.LocalLanguage != LanguageEnum.EN)
			{
				allRadioButton.Location = new Point(20, 19);
				selectedRadioButton.Location = new Point(99, 19);
			}
			else
			{
				allRadioButton.Location = new Point(6, 19);
				selectedRadioButton.Location = new Point(83, 19);
			}
		}

		// 所有控制器 + 所有端口
		private void allSubRadioButton_CheckedChanged(object sender, EventArgs e)
		{
			if (allSubRadioButton.Checked)
			{
				portGroupBox.Enabled = false;
				delMode = "AllSub_AllPort";
			}
			else
			{
				portGroupBox.Enabled = true;
				if (selectedRadioButton.Checked)
				{
					delMode = "SelectedSub_SelectedPort";
				}
				else
				{
					delMode = "SelectedSub_AllPort";
				}
			}
		}

		// 当前控制器的 所有端口 或 选定端口
		private void selectedRadioButton_CheckedChanged(object sender, EventArgs e)
		{
			if (selectedRadioButton.Checked)
			{
				delMode = "SelectedSub_SelectedPort";
			}
			else
			{
				delMode = "SelectedSub_AllPort";
			}
		}

		// 确定
		private void okButton_Click(object sender, EventArgs e)
		{
			this.DialogResult = System.Windows.Forms.DialogResult.OK;
		}
	}
}
